package mspbots.next.ticket.core.data.rules;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.Data;
import mspbots.next.ticket.core.GradingRequest;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.domain.Persistable;
import org.springframework.data.relational.core.mapping.Table;

/**
 * com.mspbots.core.ticketai.TicketGradeInfo
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2019/8/20
 */
@Data
@Table("next_ticket_rules")
public class Rule implements Persistable<Integer> {

    @Id
    private Integer id;
    private Long tenantId;
    private String name;
    private JsonNode params;
    private String displayName;
    private Boolean enable;

    @Transient
    private transient GradingRequest request;

    public Rule request(GradingRequest request) {
        this.request = request;
        return this;
    }

    @Override
    public boolean isNew() {
        return this.id == 0;
    }
}
